<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>订单管理管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		
		function getCitys(p){
			var cardNum = $("#cardNum").val();
			var password = $("#password").val();
			var name = $("#name").val();
			var mobile = $("#mobile").val();
			var address = $("#address").val();
			var remarks = $("#remarks").val();
			var productId = $("#productId").val();
			window.location.href = "${ctx}/crab/orderCreate/getCitys?province="+p.value+"&cardNum="+cardNum+
			"&password="+password+"&name="+name+"&mobile="+mobile+"&address="+address+"&remarks="+remarks+"&productId="+productId+"&companyId="+companyId;
			
		}
		
		function getCountys(c){
			var cardNum = $("#cardNum").val();
			var password = $("#password").val();
			var name = $("#name").val();
			var mobile = $("#mobile").val();
			var address = $("#address").val();
			var remarks = $("#remarks").val();
			var province = $("#province").val();
			var productId = $("#productId").val();
			window.location.href = "${ctx}/crab/orderCreate/getCountys?city="+c.value+"&cardNum="+cardNum+
			"&password="+password+"&name="+name+"&mobile="+mobile+"&address="+address+"&remarks="+remarks+"&province="+province+"&productId="+productId+"&companyId="+companyId;
		}
		
		function getProducts(){
			var cardNum = $("#cardNum").val();
			var password = $("#password").val();
			var name = $("#name").val();
			var mobile = $("#mobile").val();
			var address = $("#address").val();
			var remarks = $("#remarks").val();
			var province = $("#province").val();
			var city = $("#city").val();
			var productId = $("#productId").val();
			window.location.href = "${ctx}/crab/orderCreate/getProducts?city="+city+"&cardNum="+cardNum+
			"&password="+password+"&name="+name+"&mobile="+mobile+"&address="+address+"&remarks="+remarks+"&province="+province+"&productId="+productId+"&companyId="+companyId;
		}
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a>电话提货</a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="order" action="${ctx}/crab/orderCreate/save" method="post" class="form-horizontal">
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">兑换券号：</label>
			<div class="controls">
				<form:input path="cardNum" htmlEscape="false" maxlength="32" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">密码：</label>
			<div class="controls">
				<form:input path="password" htmlEscape="false" maxlength="6" class="input-xlarge required digits" onblur="getProducts()"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">商品：</label>
			<div class="controls">
				<form:select path="productId" class="input-medium required">
					<form:options items="${order.listProduct}" itemValue="id" itemLabel="name" htmlEscape="false"/>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>	
		<div class="control-group">
			<label class="control-label">收货人：</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="32" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">收货号码：</label>
			<div class="controls">
				<form:input path="mobile" htmlEscape="false" maxlength="15" class="input-xlarge required mobile"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">省份：</label>
			<div class="controls">
				<form:select path="province" class="input-medium required" onchange="getCitys(this)">
					<form:options items="${order.listProvince}" itemValue="code" itemLabel="name" htmlEscape="false"/>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">城市：</label>
			<div class="controls">
				<form:select path="city" class="input-medium required" onchange="getCountys(this)">
					<form:options items="${order.listCity}" itemValue="code" itemLabel="name" htmlEscape="false"/>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">区(县)：</label>
			<div class="controls">
				<form:select path="county" class="input-medium required">
					<form:options items="${order.listCounty}" itemValue="code" itemLabel="name" htmlEscape="false"/>
				</form:select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">地址：</label>
			<div class="controls">
				<form:textarea path="address" htmlEscape="false"  maxlength="255" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">期望发货日期：</label>
			<div class="controls">
				<input name="hopeDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${order.hopeDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">分公司：</label>
			<div class="controls">
				<form:select path="companyId" class="input-medium">
					<form:option value="">请选择</form:option>
					<form:options items="${fns:getCompany()}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="crab:order:save"><input id="btnSubmit" class="btn btn-primary" type="submit" value="提 交"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>